package com.xmgl.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xmgl.model.TestModel;
import com.xmgl.service.TestService;


@Controller
@RequestMapping("/test")
public class TestController {

	@Autowired
	private TestService testServer;
	
	//返回JSon数据
	@ResponseBody
	@RequestMapping("/getTestJson")
	public Object getJSon(){
		Map map = new HashMap();
		List<TestModel> users = testServer.findUsers();
		map.put("users", users);
		return map;
	}
	
	@RequestMapping(value="/getTestUser/{query}")
	public String getSomeUser(@PathVariable("query") String query,Model model){
		List<TestModel> users = testServer.findUsers(query);
		model.addAttribute("users", users);
		model.addAttribute("sizhangji","鸳鸯织就欲双飞");
		return "test";
	}
	
	
	
}
